﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace XoLib.CatchException
{
    /// <summary>
    /// Exception Dialog
    /// </summary>
    public partial class ExceptionDialog : Form
    {

        /// <summary>
        /// Constructor
        /// </summary>
        public ExceptionDialog()
        {
            InitializeComponent();

            this.Text = Path.GetFileNameWithoutExtension(System.AppDomain.CurrentDomain.FriendlyName) ;
                //System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            label1.Text = "Une erreur irrécupérable s'est produite";

            Center();
        }

        /// <summary>
        /// <para>
        /// <param name="ctrl">Control</param>
        /// </para>
        /// Center a control
        /// </summary>
        protected static void Center(Control ctrl)
        {
            Point location = new Point(
                 Screen.PrimaryScreen.WorkingArea.Width / 2 - ctrl.Width / 2,
                 Screen.PrimaryScreen.WorkingArea.Height / 2 - ctrl.Height / 2);
            ctrl.Location = location;
        }

        /// <summary>
        /// Center the form
        /// </summary>
        protected void Center()
        {
            Center(this);
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            this.Close();
            this.DialogResult = DialogResult.OK;
        }
    }
}